package org.marverse.util

/**
 * Classes that implement <code>Checkable</code> can be validated at runtime. 
 * The method {@link #check(TypedMap)} should throw an exception, if the
 * object is in an invalid state.
 */
trait Checkable {
  /**
   * Throws a runtime exception if this object is in an illegal state.
   */
  def check(implicit ctx: MutableTypedMap[TypedKey, Any])
  /**
   * Convenience method that throws an exception, if
   * the condition is false.
   */
  def assertThat(condition: Boolean, message: => String) {
    if (!condition) throw new RuntimeException(message)
  }
}
